home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
LOGIC Apps
/
Logic-APPLE_II_APPS.iso
/
pc
/
LOGIC Apple II 5.25" Library - DOS Part 3
/
DOS077A.dsk
/
PRIMES & FACTORS.int
< prev
next >
Wrap
Text File
|
2012-02-16
|
5KB
|
188 lines
0 K=0
1 REM PRIMES AND FACTORS
2 REM BY RICHARD RUTH
3 REM KEYSTONE APPLE CORE
4 REM
5 REM 12/12/79
6 REM
7 REM
8 GOSUB 3021
10 CALL -936
11 REM HEADING
12 POKE 50,63:PRINT " G E N E R A L M A T H E M A T I C S "
13 POKE 50,255
20 REM PRIME NUMBER FINDER
30 REM GCF/LCM
40 REM FACTORS OF A NUMBER
45 REM PRIME NUMBER LIST
50 VTAB 6:PRINT "HERE ARE FIVE PROGRAMS:"
60 PRINT
70 TAB (4):PRINT "1) PRIME NUMBER FINDER"
75 PRINT
80 TAB (4):PRINT "2) GCF/LCM FINDER"
85 PRINT
90 TAB (4):PRINT "3) FIND FACTORS OF A NUMBER."
100 PRINT
105 TAB (4):PRINT "4) PRIME FACTORIZATION."
106 PRINT
107 TAB (4):PRINT "5) PRIME NUMBER LIST."
110 FOR I=1 TO 1000:NEXT I:PRINT
115 PRINT
120 INPUT "WHICH DO YOU WANT<CTRL-G>",C
130 IF C>0 AND C<6 THEN 140
135 PRINT :PRINT "INPUT ONLY 1,2,3,4, OR 5!":PRINT :GOTO 120
140 PRINT :IF K=0 THEN GOSUB 2000
141 K=K+1
145 IF C=1 THEN GOSUB 500
150 IF C=2 THEN GOSUB 1000
155 IF C=4 THEN GOSUB 2200
157 IF C=5 THEN 2500
160 CALL -936
165 REM PROGRAM TO FIND INTEGRAL
166 REM FACTORS OF A NUMBER.
167 REM
170 VTAB 5:PRINT "*** FACTORS OF A NUMBER ***":PRINT
180 INPUT "WHAT IS YOUR NUMBER",N
185 IF N<1 THEN 10
190 PRINT
200 FOR I=1 TO N
205 IF I*I>N THEN 300
210 Y=N MOD I
220 IF Y=0 THEN PRINT I,N/I
240 NEXT I
300 PRINT
310 PRINT "ALL FACTORS HAVE BEEN FOUND.<CTRL-G>"
320 PRINT :FOR I=1 TO 300:NEXT I:GOTO 180
500 CALL -936
505 REM PROGRAM TO DETERMINE
506 REM WHETHER A NUMBER IS PRIME.
507 REM
510 VTAB 5:PRINT "*** PRIME NUMBER FINDER ***":PRINT
520 INPUT "WHAT IS YOUR NUMBER",N
530 PRINT :IF N>1 THEN 540
531 IF N<1 THEN 10
535 PRINT :PRINT "YOU MUST INPUT A NUMBER GREATER THAN 1<CTRL-G><CTRL-G><CTRL-G><CTRL-G> !":PRINT
536 GOTO 520
540 FOR I=2 TO N-1
550 Y=N MOD I
560 IF I*I>N THEN 600
570 IF Y=0 THEN 650
580 NEXT I
600 PRINT N;" IS A PRIME.<CTRL-G>"
610 PRINT :PRINT :GOTO 520
650 PRINT N;" IS NOT A PRIME."
660 GOTO 610
1000 CALL -936
1005 REM FIND GREATEST COMMON FACTOR
1007 REM
1010 VTAB 5:PRINT "*** PROGRAM TO FIND GCF/LCM ***":PRINT
1015 PRINT "(INPUT NUMBERS IN THE FORM A,B)":PRINT
1020 PRINT :INPUT "WHAT ARE YOUR NUMBERS ",N1,N2
1030 IF N1>0 AND N2>0 THEN 1050
1040 GOTO 10
1050 IF N2>N1 THEN 1080
1060 TEMP=N2
1065 N2=N1
1070 N1=TEMP
1075 REM FINDING THE GCF
1076 REM
1080 DVD=N2
1090 DVR=N1
1100 Y=DVD MOD DVR
1110 IF Y=0 THEN 1200
1120 DVD=DVR
1130 DVR=Y
1140 GOTO 1100
1200 GCF=DVR
1210 GOSUB 1400
1220 PRINT :INPUT "DO YOU WANT THE LCM (Y/N) ",A$
1230 IF A$#"Y" THEN 1020
1300 K=1
1301 REM FINDING LCM
1302 REM
1303 REM (NUMBERS TOO LARGE WILL
1304 REM BOMB THE PROGRAM)
1305 REM
1310 Z=(K*N2) MOD N1
1320 IF Z=0 THEN 1390
1330 K=K+1:GOTO 1310
1390 LCM=(K*N2)
1394 PRINT :PRINT
1395 GOTO 1500
1400 CALL -936:VTAB 6:PRINT "THE GCF OF ";N1;" AND ";N2;" IS ";GCF:PRINT :PRINT
1401 RETURN
1500 PRINT "AND THE LCM IS ";LCM;".":PRINT :PRINT
1600 GOTO 1020
1610 END
2000 CALL -936:VTAB 10:PRINT "<CTRL-G><CTRL-G><CTRL-G>"
2005 FOR I=1 TO 40
2010 PRINT "*";
2020 NEXT I
2030 PRINT
2040 PRINT " (ENTER A ZERO TO RETURN TO THE MENU)"
2050 PRINT
2060 FOR I=1 TO 40
2070 PRINT "*";
2080 NEXT I
2085 FOR I=1 TO 2500:NEXT I
2086 PRINT "<CTRL-G>"
2090 PRINT
2100 RETURN
2200 CALL -936
2201 PRINT "***PRIME FACTORIZATION***"
2210 PRINT :PRINT :PRINT
2215 PRINT "<CTRL-G>"
2220 INPUT "WHAT IS YOUR NUMBER ",N
2222 IF N>1 THEN 2230
2223 IF N=0 THEN 10
2224 PRINT :PRINT "INPUT A NUMBER GREATER THAN 1.":GOTO 2210
2230 FOR K=2 TO N
2240 IF (N MOD K=0)=1 THEN 3000
2250 NEXT K
2260 PRINT N," IS A PRIME."
2270 PRINT :PRINT "FINISHED!":GOTO 2210
2303 GOSUB 2800
2500 REM PRIME NUMBER LIST ROUTINE
2501 REM
2502 CALL -936:VTAB 6:PRINT "THIS PROGRAM GENERATES A LIST OF PRIMES."
2503 PRINT :PRINT :INPUT " HOW MANY PRIMES DO YOU WANT ",MAX:IF MAX=0 THEN 10
2505 PRINT :INPUT " BEGINNING AT WHAT NUMBER ",BEG
2506 IF BEG=0 THEN 10
2509 CALL -936:GOSUB 2800
2510 A=0:N=BEG
2520 FOR I=3 TO N-1
2530 IF N MOD I=0 THEN 2550
2540 NEXT I
2545 GOSUB 2700
2550 N=N+1
2560 IF A=0 OR A=1 THEN 2520
2570 IF A MOD 10#0 THEN 2520
2575 PRINT
2580 TAB 15: POKE 50,63:PRINT " PRESS SPACE BAR ": POKE 50,255
2600 IF PEEK (-16384)>127=1 THEN 2620
2610 GOTO 2600
2620 POKE -16368,0
2622 IF A=MAX THEN 2500
2625 CALL -936:GOSUB 2800
2630 N=N+1:GOTO 2520
2700 REM PRINT A PRIME
2710 PRINT :PRINT "(";A+1;").",N
2712 A=A+1
2715 IF A=MAX THEN 2900
2720 RETURN
2800 POKE 50,63:PRINT " P R I M E N U M B E R L I S T ": POKE 50,255:RETURN
2900 PRINT " (FINISHED!)<CTRL-G>"
2901 FOR I=1 TO 500:NEXT I
2902 GOTO 2580
3000 PRINT :PRINT K," IS A PRIME FACTOR."
3010 N=N/K
3015 IF N=1 THEN 2270
3020 GOTO 2230
3021 CALL -936:VTAB 8:TAB 10
3022 POKE 50,63:PRINT " *PRIMES AND FACTORS ": POKE 50,255:PRINT
3023 TAB 13:PRINT "BY RICHARD RUTH":PRINT
3024 TAB 11:PRINT "KEYSTONE APPLE CORE":PRINT
3025 TAB 17:PRINT "12/12/79"
3026 FOR N=1 TO 2500:NEXT N:RETURN
3030 END